---
title: LegalManagerBase.OnContextChanged
summary: resolve legal case context
status: draft
owner: SAIF Documentation Generator
last_reviewed: 2026-08-21
library: SAIF.Application.Claim.Legal
reference_type: embedded
operation_id: OP-001
trigger: resolve legal case context
---

# LegalManagerBase.OnContextChanged

Resolve legal case context.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-001 |
| **Trigger** | resolve legal case context |
| **Inputs** | Current manager state, current claim/case context, and any workflow-specific parameters or collections. |
| **Outputs** | Updated collections, messages, or side effects specific to the operation. |
| **Primary components** | `LegalManagerBase.OnContextChanged` |
| **Entry point** | `SAIF.Application.Claim.Legal\LegalManagerBase.vb` |

## Steps

1. Clear the internal case list and current case.
2. If `ContextSet` is true: call `MarkContextSet`, then `clsFindCase.GetCases(DPI, ClaimData.ClaimNumber)` to build the case list; select the first case.
3. Otherwise: treat `ContextNumber.ToUpper` as a WCB or DCBS number and resolve the matching legal case.
4. Call `SetClaimContext(CurrentCase.Claim.ClaimNumber)` to align claim context, then re-select the case in the rebuilt list.

- Primary rules: [BR-011](../business-rules.md#br-011-legal-case-context-can-be-established-from-a-claim-number%2C-wcb-number%2C-or-dcbs-number)

## Failure and edge-case behavior

- Failures surface as manager messages or blocked workflow actions specific to the source operation.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
  Start([Trigger]) --> S1[Load current state]
  S1 --> S2[Apply operation rules]
  S2 --> D{"Validation or security<br>issue?"}
  D -->|Yes| EndErr(["Return message or block<br>action"])
  D -->|No| EndOk(["Return updated workflow<br>state"])
```

## Related documentation
- [Index](../index.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Security and authorization](../security-authorization.md)
- [Database tables](../database-tables.md)
- [SQL catalog](../sql/index.md)
- [Procedures](../procedures/index.md)
- [API reference](../api/index.md)

## Sources
- SAIF.Application.Claim.Legal\LegalManagerBase.vb
